<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <h1>BMI测试</h1>
  <input type="text" v-model="person.h" placeholder="身高">
  <input type="text" v-model="person.w" placeholder="体重">
  <input type="button" value="开始测试" @click="f1()">
  <hr>
    <input type="text" v-model="h" placeholder="身高">
    <input type="text" v-model="w" placeholder="体重">
    <input type="button" value="开始测试" @click="f()">
    <h2>{{result}}</h2>

</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            result:"",
            h:"",
            w:"",
            person:{
                h:"",
                w:"",

            }
        },
        methods:{
            f(){
                axios.get("/bmi?h="+v.h+"&w="+v.w).then(function (response) {
                    v.result = response.data;
                })
            },
            f1(){
                axios.post("/postBmi",v.person).then(function (response) {
                    alert(response.data)
                })
            }
        }
    })
</script>
</body>
</html>